package com.gpjcjl.adapter;

import android.content.Context;
import android.view.View;

import com.gpjcjl.R;
import com.gpjcjl.entity.RecordDetail;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

/**
 * 原始记录详情（钢瓶列表）适配器
 *
 * @author yinbiao
 * @date 2020-10-26 09:28:37
 */
public class RecordDetailAdapter extends BaseRecyclerAdapter<RecordDetail> {

    private OnDeleteListener onDeleteListener;

    public RecordDetailAdapter(Context context, List<RecordDetail> datas) {
        super(context, R.layout.item_record_detail, datas);
    }

    @Override
    protected void convert(ViewHolder holder, RecordDetail detail, int position) {
        holder.setText(R.id.tv_num, "检测编号：" + detail.getCheck_num());
        holder.setText(R.id.tv_date, "生产日期：" + detail.getProduce_time());
        holder.setText(R.id.tv_produce, detail.getProduce());
        holder.setOnClickListener(R.id.btn_delete, v -> {
            if (onDeleteListener != null) {
                onDeleteListener.onDelete(position);
            }
        });
    }

    public void setOnDeleteListener(OnDeleteListener onDeleteListener) {
        this.onDeleteListener = onDeleteListener;
    }

    public interface OnDeleteListener {
        void onDelete(int position);
    }

}

